/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

/**
 *
 * @author tg300
 */
public class Die {

    private int numberRolled;
    /**
     * Get the value of numberRolled
     *
     * @return the value of numberRolled
     */
    public int getNumberRolled() {
        return numberRolled;
    }

    public Die() {
    //the default constructor creates a 6-sided die
    this.numberOfSides = 6;
    }

    public Die(int numberOfSides) {
        this.numberOfSides = numberOfSides;
    }

     public int roll()
    {
        this.numberRolled = (int)(this.numberOfSides * Math.random()) + 1;
        return numberRolled;
    }

    /**
     * Set the value of numberRolled
     *
     * @param numberRolled new value of numberRolled
     */
    public void setNumberRolled(int numberRolled)

       throws IllegalArgumentException
        {
        if(numberRolled < 0 || numberRolled > this.getNumberOfSides())
        {
        throw new IllegalArgumentException("Must be a number between 1 and "+  this.getNumberOfSides());
        }
        {
        this.numberRolled = numberRolled;
        }
        }

    private int numberOfSides;

    /**
     * Get the value of numberOfSides
     *
     * @return the value of numberOfSides
     */
    public int getNumberOfSides()
    {
        return numberOfSides;
    }

    /**
     * Set the value of numberOfSides
     *
     * @param numberOfSides new value of numberOfSides
     */
    public void setNumberOfSides(int numberOfSides)
    {
        this.numberOfSides = numberOfSides;
    }

     public void reset(){
        this.numberOfSides = 0;
        this.numberRolled = 0;

    }

}
